import 'package:json_annotation/json_annotation.dart';

part 'store_index.g.dart';

@JsonSerializable()
class StoreIndex {
  final Store store;
  @JsonKey(defaultValue: [])
  final List<Link> navigator;
  @JsonKey(defaultValue: [])
  final List<Link> bannerList;
  @JsonKey(defaultValue: [])
  final List<Link> newsList;
  @JsonKey(defaultValue: [])
  final List<Link> hotList;
  @JsonKey(defaultValue: [])
  final List<Link> recommendList;
  @JsonKey(defaultValue: [])
  final List<Floor> floorList;

  StoreIndex(
    this.store,
    this.navigator,
    this.bannerList,
    this.newsList,
    this.hotList,
    this.recommendList,
    this.floorList,
  );

  factory StoreIndex.fromJson(Map<String, dynamic> json) => _$StoreIndexFromJson(json);

  Map<String, dynamic> toJson() => _$StoreIndexToJson(this);
}

@JsonSerializable()
class Store {
  final int id;
  final String name;
  final String logoUrl;

  Store(this.id, this.name, this.logoUrl);

  factory Store.fromJson(Map<String, dynamic> json) => _$StoreFromJson(json);

  Map<String, dynamic> toJson() => _$StoreToJson(this);
}

@JsonSerializable()
class Floor {
  final String title;
  final List<Link> productLinks;

  Floor(this.title, this.productLinks);

  factory Floor.fromJson(Map<String, dynamic> json) => _$FloorFromJson(json);

  Map<String, dynamic> toJson() => _$FloorToJson(this);
}

@JsonSerializable()
class Link {
  final int id;
  final String title;
  final String content;
  final String image;
  final String displayType;
  final int modelInAreaId;
  final String createTime;
  final String creatorName;
  final int storeId;
  final int storeAreaId;
  final DateTime startTime;
  final DateTime endTime;
  final DateTime serverTime;

  Link(
    this.id,
    this.title,
    this.content,
    this.image,
    this.displayType,
    this.modelInAreaId,
    this.createTime,
    this.creatorName,
    this.storeId,
    this.storeAreaId,
    this.startTime,
    this.endTime,
    this.serverTime,
  );

  factory Link.fromJson(Map<String, dynamic> json) => _$LinkFromJson(json);

  Map<String, dynamic> toJson() => _$LinkToJson(this);
}
